#include<pthread.h>

//对锁进行封装调用
class mutex{
public:
    mutex(pthread_mutex_t* mutex):mutex_(mutex)
    {}

    void lock()
    {
        pthread_mutex_lock(mutex_);
    }

    void unlock()
    {
        pthread_mutex_unlock(mutex_);
    }

    ~mutex()
    {}
private:
    pthread_mutex_t* mutex_;
};

class Guard{
public:
    Guard(pthread_mutex_t* mute):mt_(mutex(mute))
    {
        mt_.lock();
    }

    ~Guard()
    {
        mt_.unlock();
    }

private:
    mutex mt_;
};